跳到主要内容
版本:FCP 24.08

Ansys Mechanical

parameters:
- name: input_file
display: 输入文件
type: path
required: true
- name: job_name
display: 任务名称
type: string
required: true
- name: np
display: 每个节点并发数
type: int
required: true
usage: SCHEDULER
schedPrefix: --ntasks-per-node
option:
int:
min: 1
max: 48
- name: node_num
display: 节点数
type: enum
required: true
usage: SCHEDULER
schedPrefix: -N
option:
enum:
- value: 1
display: 1
outputs:
- path: taskout.log
type: TEXT
script: |-
#!/bin/bash
set -ex

export ANSYSLMD_LICENSE_FILE=27005@10.105.1.10

NODELIST=/fastone/softwares/nodelist
MECHENICAL=/fastone/softwares/ansys/ansys/2023/ansys_inc/v232/ansys/bin/ansys232

LOGFILE=taskout.log

# check if we run from slurm
if [[ -z "${SLURM_JOB_NODELIST}" ]]; then
echo "only support runs withing slurm!"
exit 1
fi

INPUT={{ input_file }}

JOBNAME={{ job_name }}

if [ -z "${INPUT}" ]; then
echo "ERROR: missing input"
exit 1
else
cp -rf ${INPUT} .
CASEFILE=$(basename ${INPUT})
fi

if [ -z "${JOBNAME}" ]; then
echo "ERROR: missing jobname"
exit 1
fi

# 检查输入文件后缀
function check_input_file(){
if [ -n "$1" ];then
input_file_status=0
for sub_str in $(echo "$1" | tr "," " ")
do
if $(echo ${2}|grep -i ${sub_str} >/dev/null 2>&1);then
input_file_status=0
break
else
input_file_status=1
fi
done

if [ ${input_file_status} -ne 0 ];then
echo "Invalid inputs file"
exit 2
fi
fi
}


# override home directory
export HOME=$PWD

check_input_file ".dat" ${CASEFILE}

# run in MPP mode with machines
{{ "MACHINES=$(${NODELIST} -delim : -format '{{.Host}}:{{.Cpu}}')" }}

${MECHENICAL} -dis -b -i ${CASEFILE} -j ${JOBNAME} -machines ${MACHINES} > ${LOGFILE}